from django.db import models


# Create your models here.
class Category(models.Model):
    title = models.CharField(verbose_name='类名', max_length=30, unique=True)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = "类别"
        verbose_name_plural = "类别"


class Book(models.Model):
    title = models.CharField(verbose_name="书名", max_length=30, unique=True)
    pub_date = models.DateField(verbose_name='出版日期', auto_now_add=True)
    category = models.ForeignKey(verbose_name='分类', to='Category', on_delete=models.CASCADE)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = "书籍"
        verbose_name_plural = "书籍"
